home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 874 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.4 KB

  1. Path: engnews1.Eng.Sun.COM!taumet!clamage
  2. From: sjc@netcom.com (Steven Correll)
  3. Newsgroups: comp.std.c++
  4. Subject: delete vs incomplete class type
  5. Date: 27 Mar 1996 15:46:53 GMT
  6. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  7. Approved: clamage@eng.sun.com (comp.std.c++)
  8. Message-ID: <sjcDownA7.6FA@netcom.com>
  9. NNTP-Posting-Host: taumet.eng.sun.com
  10. Apparently-To: comp-std-c++@uunet.uu.net
  11. Content-Length: 1578
  12. X-Lines: 35
  13. Originator: clamage@taumet
  14.  
  15. What must a conforming compiler do when confronted with this?
  16.  
  17.         struct x;
  18.         struct y;
  19.  
  20.         void
  21.         p(x *arg0, y *arg1)
  22.           {
  23.           delete [] arg0;
  24.           delete arg1;
  25.           }
  26.  
  27. Section 5.3.5 of my 5/95 copy of the draft standard says "If the object
  28. being deleted has incomplete class type at the point of deletion and the
  29. class has a non-trivial destructor...the behavior is undefined." Is this
  30. still true?
  31.  
  32. I don't see how a compiler could avoid noticing that it hasn't a clue what
  33. destructor to invoke at compilation time. Is there a reason (aside from
  34. encouraging people to migrate to Java) not to require the compiler to
  35. diagnose this as an error, instead of allowing it to fault at execution
  36. time? (Given that x and y might be PODS, I doubt that it's possible to
  37. defer the solution to execution time, but if it is, then why not define
  38. the behavior and mandate that it be correct?)
  39.  
  40. Forgive me for being testy, but I've spent days debugging this error in a
  41. program generated with the Solaris 3.0.1 compiler, where the undefined "delete"
  42. for "arg0" in the example above can cause a failure during a perfectly correct
  43. and well-defined "delete" of a totally unrelated object (the undefined "delete"
  44. deallocates memory but fails to remove an entry from a table in the runtime
  45. library; if the "new" of the other object happens to reuse the same block of
  46. memory, it puts a redundant entry into the table, and a well-defined "delete"
  47. of that object blows up.)
  48. -- 
  49. Steven Correll == PO Box 66625, Scotts Valley, CA 95067 == sjc@netcom.com
  50.  
  51.  
  52. [ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
  53. [ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
  54. [ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
  55. [ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
  56. [ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
  57.